<script type="text/javascript">
$(function () {
	var url = '${contextPath}script/sys/organ.js';
	$.ajax({url:url, dataType:'script', cache:true,
		success: function(){
			//loadScript_organ();
		}
	});
	$('#editOrganForm').find("input:checkbox, input:radio").not('input.ibtn').uniform();
});
var map;
var mousetool;
var  marker;
function init_organ() {
	var d = new Date();
	var position = new AMap.LngLat(parseFloat(<#if longitude?? &&  longitude != "">${(longitude)!''}<#else>106.710237</#if>), parseFloat(<#if latitude?? &&  latitude != "">${(latitude)!''}<#else>26.533338</#if>));//创建中心点坐标, 贵阳小城故事为中心
    map = new AMap.Map("mapDiv", {
		center : position,
		level : 15  //地图显示的缩放级别
	});
	marker = new AMap.Marker({     
     });     
	marker.setMap(map); 
	//添加寻找坐标的click事件
	var clickEventListener = AMap.event.addListener(map,'contextmenu',function(e){  
	        $("#lo").val(e.lnglat.getLng());  
	        $("#la").val(e.lnglat.getLat()); 
	        clickGetPoints_organ(e.lnglat.getLng(),e.lnglat.getLat());
        }); 
	//加载工具条
	map.plugin([ "AMap.ToolBar", "AMap.Autocomplete", "AMap.CitySearch", "AMap.DragRoute", "AMap.Hotspot","AMap.MouseTool","MapType"],
			function() {
				var tool = new AMap.ToolBar();
				var view = new AMap.OverView();
				var type= new AMap.MapType({defaultType:0});//初始状态使用2D地图  
				mousetool = new AMap.MouseTool(map);
      		    map.addControl(type); 
				map.addControl(tool);
				//map.addControl(view); // 鹰眼
			});
	createMarkers(${(od)!"[]"}, map);
}
$('#editOrganForm').find("input:checkbox, input:radio").not('input.ibtn').uniform();
</script>

<#import "/freemarker/modeltype.ftl" as mt>
<#import "/freemarker/modeltype_entity.ftl" as mte>
<div>
	<h3 class="title"><i class="fontello-icon-th-list-1"></i> 编辑机构信息</h3>
</div>
<form id="editOrganForm">
<table class="table table-striped">
	<tbody>
		<tr>
			<td class="table-left" style="width:80px;">名称</td>
			<td style="width:350px;"><input class="form-control" type="text" id="name" name="name" value="${(organ.name)!''}" style="width:300px;" />
				<input  type="hidden" id="code" name="code" value="${(organ.code)!''}" />
				<input  type="hidden" name="details.code" value="${(organ.details.code)!''}" />
			</td>
			<td class="table-left">上级机构</td>
			<td>
				<div class="input-group" style="width:400px;">
					<span class="btn-group">
						<input class="form-control" type="text" name="pn" id="pn" value="${(organ.pn)!''}" readonly style="width: 225px;">
						<input class="form-control" type="hidden" name="pc" id="pc" value="${(organ.pc)!''}" />
						<button class="btn btn-primary" onclick="javascript: selectParent_organ(${(organ.code)!(organ.pc)!''}); return false;"><i class="icon-search"></i></button>
						<button class="btn btn-danger" onclick="javascript: $('#pc').val(''); $('#pn').val(''); return false;"><i class="icon-remove"></i></button>
					</span>
				</div>
			</td>
		</tr>
		<tr>
			<td style="width:80px;" class="table-left">简称</td>
			<td><input class="form-control" type="text" id="abbname" name="abbname" value="${(organ.abbname)!''}" style="width:300px;" /></td>
			<td style="width:80px;" class="table-left">网址</td>
			<td><input class="form-control" type="text" id="site" name="details.site" value="${(organ.details.site)!''}" style="width:300px;" /></td>
		</tr>
		<tr>
			<td class="table-left">电话</td>
			<td><input class="form-control" type="text" id="phone" name="details.phone" value="${(organ.details.phone)!''}" style="width:300px;" /></td>
			<td class="table-left">传真</td>
			<td><input class="form-control" type="text" id="fax" name="details.fax" value="${(organ.details.fax)!''}" style="width:300px;" /></td>
		</tr>
		<tr>
			<td class="table-left">Email</td>
			<td><input class="form-control" type="text" id="email" name="details.email" value="${(organ.details.email)!''}" style="width:300px;" /></td>
			<td class="table-left">地址</td>
			<td><input class="form-control" type="text" id="address" name="details.address" value="${(organ.details.address)!''}" style="width:300px;" /></td>
		</tr>
		<tr>
			<td class="table-left">邮编</td>
			<td><input class="form-control" type="text" id="postal" name="details.postal" value="${(organ.details.postal)!''}" style="width:80px;" /></td>
			<td class="table-left">负责人</td>
			<td><input class="form-control" type="text" id="manager" name="manager" value="${(organ.manager)!''}" style="width:300px;" /></td>
		</tr>
		<tr>
			<td class="table-left">经度</td>
			<td><input class="form-control" type="text" id="longitude1" name="details.longitude" value="${(organ.details.longitude)!''}" style="width:80px;" /></td>
			<td class="table-left">纬度</td>
			<td>
				<input class="form-control" type="text" id="latitude1" name="details.latitude" value="${(organ.details.latitude)!''}" style="width:300px;" />
				<input type="hidden" id="lo"  value="${(organ.details.longitude)!''}"/>
				<input type="hidden" id="la"  value="${(organ.details.latitude)!''}"/>
			</td>
		</tr>
		<tr>
			<td class="table-left">机构类型</td>
			<td><@mte.OrganType value=((organ.otc)!"") id='otc' name='otc' pc='0' classname="form-control" /></td>
			<td class="table-left">是否屏蔽</td>
			<td><@mt.YesOrNo value=((organ.deleted)!false) r=true name='deleted' d=false mc=false /></td>
		</tr>
		<tr>
			<td colspan="3"  style="text-align: center; height:30px;">
				<button class="btn btn-info" onclick="javascript:saveOrgan_organ(); return false;"><i class="icon-save"></i> 保 存 </button>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<button class="btn btn-primary" onclick="javascript:history.back(); return false;"><i class="icon-signout"></i> 取 消 </button>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<button class="btn btn-success" onclick="show_organ(); return false;"><i class="icon-signout"></i>选择经纬度 </button>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<a id="crawl" style="display: none;" class="btn btn-info" href="javascript:;" onclick="crawlPoint_organ();return false;" ><i class="icon-floppy"></i>抓取坐标</a>
			</td>
		</tr>
	</tbody>
</table>
</form>

<div id="show" style="display: none;">
<div id="mapDiv" style="width:90%;height:400px;" class="myMap"></div>
<div>使用右上角的地图切换插件进行地图类型切换</div>
</div>  
